package com.ruoyi.factorydata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.factorydata.domain.StockOutOrderDetail;
import com.ruoyi.factorydata.service.IStockOutOrderDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库单详情Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/warehouse/stockOutOrderDetail")
public class StockOutOrderDetailController extends BaseController
{
    @Autowired
    private IStockOutOrderDetailService stockOutOrderDetailService;

    /**
     * 查询出库单详情列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockOutOrderDetail stockOutOrderDetail)
    {
        startPage();
        List<StockOutOrderDetail> list = stockOutOrderDetailService.selectStockOutOrderDetailList(stockOutOrderDetail);
        return getDataTable(list);
    }

    /**
     * 导出出库单详情列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:export')")
    @Log(title = "出库单详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockOutOrderDetail stockOutOrderDetail)
    {
        List<StockOutOrderDetail> list = stockOutOrderDetailService.selectStockOutOrderDetailList(stockOutOrderDetail);
        ExcelUtil<StockOutOrderDetail> util = new ExcelUtil<StockOutOrderDetail>(StockOutOrderDetail.class);
        util.exportExcel(response, list, "出库单详情数据");
    }

    /**
     * 获取出库单详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stockOutOrderDetailService.selectStockOutOrderDetailById(id));
    }

    /**
     * 新增出库单详情
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:add')")
    @Log(title = "出库单详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockOutOrderDetail stockOutOrderDetail)
    {
        return toAjax(stockOutOrderDetailService.insertStockOutOrderDetail(stockOutOrderDetail));
    }

    /**
     * 修改出库单详情
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:edit')")
    @Log(title = "出库单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockOutOrderDetail stockOutOrderDetail)
    {
        return toAjax(stockOutOrderDetailService.updateStockOutOrderDetail(stockOutOrderDetail));
    }

    /**
     * 删除出库单详情
     */
    @PreAuthorize("@ss.hasPermi('warehouse:stockOutOrderDetail:remove')")
    @Log(title = "出库单详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stockOutOrderDetailService.deleteStockOutOrderDetailByIds(ids));
    }
}
